import React, { Component } from 'react';
import { Icon } from 'antd';
import styles from './Toggles.less';
import PropTypes from 'prop-types';

class Toggles extends Component {
  constructor(props){
    super(props);
    this.state = {
      toggle: false
    }
  };

  handlerToggle = () => {
    this.setState({
      toggle: this.state.toggle ? false : true
    })
  };

  render(){
    const { children, name } = this.props;
    return (
      <div className = {styles.searchForm}>
        <a onClick = {this.handlerToggle}>
          {name}
          <Icon type={this.state.toggle ? 'up' : 'down'}/>
        </a>
        <div style={{margin:10,display:this.state.toggle?'none':'' }}>
          {children}
        </div>
      </div>
    );
  }
}

Toggles.propTypes = {
  name: PropTypes.string
};

export default Toggles;
